import axiosUpdate from '@/utils/http';

/* eslint-disable */
const rwsUrl =
  process.env.NODE_ENV === 'development'
    ? 'http://dev.c85eaf0d05d04465a81befded3f4f608b.cn-shenzhen.alicontainer.com'
    : window.location.origin;
const testUrl = 'http://127.0.0.1:18080';
const authorityUrl =
  process.env.NODE_ENV === 'development'
    ? 'http://dev.c85eaf0d05d04465a81befded3f4f608b.cn-shenzhen.alicontainer.com'
    : window.location.origin;

// 查询campaign list
export function getCampaignList(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/taskOrder/profile/getCampaignList?currentPage=${
      data.currentPage
    }&pageSize=${data.pageSize}&condition=${data.condition}&campaignId=${
      data.campaignId
    }&resultCode=${data.resultCode}&orderBy=${data.orderBy}`
  );
}

// 查询campaign list
export function modifyCampaign(data) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/taskOrder/profile/modifyCampaign`,
    method: 'POST',
    data,
  });
}

// 查询用户权限
export function getUserAuthorities(params) {
  // 'portal' 用window.AppGlobal.webroot代替
  return axiosUpdate.get(
    `${authorityUrl}${window.AppGlobal.webroot || '/portal'}/components/independents/${
      params.userId
    }`
  );
}

// dictionary配置查询
export function getDictionaryConfig(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/taskOrder/common/getDictionaryConfig?dictType=${
      data.dictType
    }&dictSubType=${data.dictSubType}`
  );
}

// dictionary配置查询
export function retrieveFile(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/taskOrder/campaign/retrieveFile?campaignId=${
      data.retrieveCampaignId
    }&sasCode=${data.sasCode}`
  );
}

// Attr Config查询
export function getAttrConfig(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/taskOrder/common/getAttrConfig?attrCode=${data.attrCode}`
  );
}

// queryActiveCampaignTotal查询
export function queryActiveCampaignTotal(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/taskOrder/campaign/queryActiveCampaignTotal?sasCode=${data.sasCode}`
  );
}
